# coding=utf-8
# author=haishan09@gmail.com
import json
from django.http import HttpResponse
from dimension.models import Dimension
from django.views.generic import View 


class DimensionChoicesView(View):

    def get(self, request, dimension_id=None, **kwargs):
        dim = Dimension.objects.get(pk=dimension_id)
        choices = dim.get_choices(cuts=request.GET)
        return HttpResponse(json.dumps([{'label': v, 'value': k} for (k, v) in choices], ensure_ascii=False))

